package com.gestion.controlador;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;

/**
 * @author Mauri@<itsoluciones.com.ar>
 */
public class UIControlador {

    private JDesktopPane jDesktopPane;

    private UIControlador() {
        //System.out.println(this.toString());
    }

    /**
     * Retorna la instancia
     * @return INSTANCE
     */
    public static UIControlador getInstance() {
        return UIControladorHolder.INSTANCE;
    }

    private static class UIControladorHolder {

        private static final UIControlador INSTANCE = new UIControlador();
    }

    /**
     *
     * @return jDesktopPane
     */
    public JDesktopPane getjDesktopPane() {
        return jDesktopPane;
    }

    /**
     *
     * @param jDesktopPane
     */
    public void setjDesktopPane(JDesktopPane jDesktopPane) {
        this.jDesktopPane = jDesktopPane;
    }

    /**
     * agrega un JInternalFrame
     * @param component 
     */
    public void agregarVista(JInternalFrame component) {
        getjDesktopPane().add(component);
        component.setVisible(true);
    }

    /**
     * elimina un JInternalFrame
     * @param component
     */
    public void quitarVista(JInternalFrame component) {
        getjDesktopPane().remove(component);
        component.setVisible(false);
        component.dispose();
    }
}
